﻿Imports System.Data.SqlClient

Public Class clsDiasTrabajoDiesel
    Private mintDia As Integer
    Private mintMes As Integer
    Private mintAnio As Integer

    Public Property Dia() As Integer
        Get
            Return mintDia
        End Get
        Set(ByVal value As Integer)
            mintDia = value
        End Set
    End Property
    Public Property Mes() As Integer
        Get
            Return mintMes
        End Get
        Set(ByVal value As Integer)
            mintMes = value
        End Set
    End Property
    Public Property Anio() As Integer
        Get
            Return mintAnio
        End Get
        Set(ByVal value As Integer)
            mintAnio = value
        End Set
    End Property

    Public Sub New()
        mintDia = 0
        mintMes = 0
        mintAnio = 0
    End Sub
    Public Sub Borrar()

        Call SetSqlCitra("Delete From DiaTrabajadoDiesel Where Dia = " & Dia & " and Mes=" & Mes & " and Anio=" & Anio)

    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into DiaTrabajadoDiesel (" & _
                            "Dia," & _
                            "Mes," & _
                            "Anio) " & _
                            "VALUES (" & _
                            "@Dia," & _
                            "@Mes," & _
                            "@Anio)"



        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("Dia", mintDia)
        Command.Parameters.AddWithValue("Mes", mintMes)
        Command.Parameters.AddWithValue("Anio", mintAnio)

        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el dia ", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
